package com.xy.order.controller;

import com.xy.order.anotation.MyAnotion;
import com.xy.order.entity.Course;
import com.xy.order.feign.StockFeign;
import com.xy.order.mapper.CourceMapper;
import com.xy.order.service.OrderService;
import com.xy.order.utils.FilesUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    public StockFeign stockFeign;

    @Autowired
    public OrderService orderService;


    @RequestMapping(value = "/saveOrder", method = RequestMethod.GET)
    public String getList(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
        FilesUtils.downloadHttpFile("https://haokan.baidu.com/791c93d5-f166-413d-bbf0-7f4956a9d208",httpServletRequest,httpServletResponse,"zhangsa");

//       // FilesUtils.downloadFile("F:\\java_back_project\\2-ShardingJDBC分库分表实战指南.pdf",httpServletRequest,httpServletResponse,"sanxing");
//
//        List<Map<String, String>> pathList  = new ArrayList<>();
//        Map map = new HashMap();
//        map.put("name","sanxing.pdf");
//        map.put("path","F:\\java_back_project\\2-ShardingJDBC分库分表实战指南.pdf");
//        pathList.add(map);
//        FilesUtils.zipDirFileToFile(pathList,httpServletRequest,httpServletResponse);
        return "save success";
    }


    @RequestMapping(value = "/saveOrder", method = RequestMethod.PUT)
    public String getListPut() {
        orderService.saveOrder();
        return "save success";
    }

    @RequestMapping(value = "/test", method = RequestMethod.GET)
    @MyAnotion(name = "aaa")
    public String test() {
        orderService.test();
        return "save success";
    }
}

